import { BroadCastCall } from "../broadCast/BroadCastCall";
import { MessageBlock } from "../../../../Framework/MQ/MessageBlock";
import { SReplyMsg } from "../../../../Message/Game/SReplyMsg";
import { NetDispatcher } from "../../../mvc/core/NetDispatcher";
import { ServerCommand } from "../../mvc/ServerCommand";
import { Cache } from "../../cache/Cache";
import { EFriendReplyResult } from "../../../../Message/Game/EFriendReplyResult";
import { MsgManager } from "../../manager/MsgManager";
//class FriendReplyCommand
    
    export  class FriendReplyCommand extends BroadCastCall
    {
        constructor(arg1: Object)
        {
            super(arg1);
            return;
        }

        public /* override */ call(arg1: MessageBlock): void
        {
            super.call(arg1);
            var loc1=arg1.messageBase as SReplyMsg;
            NetDispatcher.dispatchCmd(ServerCommand.FriendReply, loc1);
            this.addTipAndBroadCast(loc1);
            return;
        }

        /* internal  */addTipAndBroadCast(arg1: SReplyMsg): void
        {
            var loc1=arg1.applicant.name;
            var loc2=arg1.replier.name;
            var loc3=Cache.instance.role.playerInfo.name != arg1.applicant.name ? false : true;
            var loc4="";
            if (arg1.result != EFriendReplyResult._EFriendReplyResultAccept) 
            {
                if (arg1.result != EFriendReplyResult._EFriendReplyResultReject) 
                {
                    if (arg1.result != EFriendReplyResult._EFriendReplyApplicantAmountLimit) 
                    {
                        if (arg1.result == EFriendReplyResult._EFriendReplyReplierAmountLimit) 
                        {
                            if (loc3) 
                            {
                                loc4 = loc2 + "拒绝添加您为好友";
                            }
                            else 
                            {
                                loc4 = "好友已满，添加好友失败";
                            }
                        }
                    }
                    else if (loc3) 
                    {
                        loc4 = "";
                    }
                    else 
                    {
                        loc4 = loc1 + "好友已满，无法添加";
                    }
                }
                else if (loc3) 
                {
                    loc4 = loc2 + "拒绝添加您为好友";
                }
            }
            else if (loc3) 
            {
                loc4 = loc2 + "同意添加您为好友";
            }
            else 
            {
                loc4 = "添加" + loc1 + "为好友成功";
            }
            if (loc4 == "") 
            {
                return;
            }
            MsgManager.addTipText(loc4);
            MsgManager.showRollTipsMsg(loc4);
            return;
        }
    }
